import { ObjCreate } from "../../common/ObjCreate";
import { Language } from "../../../../../extend/language/Language";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GLabel } from "../../../../../com/mui/controls/GLabel";
//class EquipmentSwordProgress
    
    export  class EquipmentSwordProgress /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.createChildren();
            return;
        }

        /* internal  */createChildren(): void
        {
            this._swordBottom = new Object /* flash.display.Bitmap */();
            this._swordBottom.x = 56;
            this._swordBottom.y = 0;
            this.addChild(this._swordBottom);
            this._swordBody = new Object /* flash.display.Bitmap */();
            this._swordBody.x = 50;
            this._swordBody.y = 0;
            this.addChild(this._swordBody);
            this._progressMask = new Object /* flash.display.Bitmap */(new Object /* flash.display.BitmapData */(224, 25, true, 0));
            this._progressMask.x = 60;
            this._progressMask.y = 0;
            this.addChild(this._progressMask);
            this._swordBody.mask = this._progressMask;
            this._progressCursor = new Object /* flash.display.Bitmap */();
            this._progressCursor.x = 102;
            this._progressCursor.y = -12;
            this.addChild(this._progressCursor);
            this._swordHead = new Object /* flash.display.Bitmap */();
            this.addChild(this._swordHead);
            this._descLabel = ObjCreate.createLabel(Language.getString(60286), 112, 25, 100, 20, flash.text.TextFormatAlign.LEFT, this, false, 16776960);
            LoaderHelp.addResCallBack("EquipmentSword.swf", this.onResourceLoaded);
            return;
        }

        /* internal  */onResourceLoaded(): void
        {
            this._swordBottom.bitmapData = GlobalClass.getBitmapData(ImagesConst.equipment_sword_bottom);
            this._swordBody.bitmapData = GlobalClass.getBitmapData(ImagesConst.equipment_sword_body);
            this._swordHead.bitmapData = GlobalClass.getBitmapData(ImagesConst.equipment_sword_head);
            this._progressCursor.bitmapData = GlobalClass.getBitmapData(ImagesConst.equipment_sword_progress);
            return;
        }

        public setValue(arg1: number, arg2: number): void
        {
            if (arg2 == 0) 
            {
                arg1 = 0;
                arg2 = 100;
            }
            if (arg1 >= arg2) 
            {
                arg1 = arg2;
                this._progressCursor.visible = false;
            }
            else 
            {
                this._progressCursor.visible = true;
            }
            this._progressMask.scaleX = arg1 / arg2;
            this._progressCursor.x = this._progressMask.x + 224 * this._progressMask.scaleX - 20;
            if (arg1 != 0) 
            {
                this._descLabel.htmlText = Language.getString(60286) + Math.round(100 * arg1 / arg2) + "%";
            }
            else 
            {
                this._descLabel.htmlText = "";
            }
            return;
        }

        public get descLabel(): GLabel
        {
            return this._descLabel;
        }

        /* internal */ /* var */_descLabel: GLabel;

        /* internal */ /* var */_swordHead: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_swordBottom: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_swordBody: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_progressMask: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_progressCursor: Object /* flash.display.Bitmap */;
    }
